/*
 * @Author: xiehangyun 
 * @Date: 2025-05-16 10:49:46 
 * @Last Modified by: 肖思汗
 * @Last Modified time: 2025-07-06 15:18:20
 */

import Api from "src/api/Api";

// 确认订单的接口
class ConfirmOrderApi extends Api {
    constructor() {
        super();
    }

    // 提交订单
    submitOrder(orderData: any) {
        return this._post("/order/submit", { data: orderData });
    }

    // 获取微信支付参数
    wechatPay(orderId: string) {
        return this._post("/payment/wechat", {
            data: { orderId }
        });
    }

    // 获取订单详情
    getOrderDetail(orderId: string) {
        return this._get(`/order/detail?id=${orderId}`);
    }

    // 更新订单信息
    updateOrder(orderId: string, updateData: any) {
        return this._post(`/order/update?id=${orderId}`, { data: updateData });
    }

    // 配送方式分页查询
    listDistributionMode() {
        return this._get(`/distribution/mode/listDistributionMode`);
    }

    // 获取包装费用map
    getPackges(appAddressId: number, distributionModeId: number) {
        return this._get('/productOrder/getPackagePriceMap', {
            appAddressId,
            distributionModeId
        });
    }

    // 根据购物车商品和选择快递公司计算运费
    calculateDeliveryPrice(data: {
        shopCartIds: string, // 购物车id
        appAddressId: string; // 用户地址id
        distributionModeId: string; // 快递公司id
        packagePriceType: string; // 包装费用类型
        couponId?: number; // 优惠券id
    }) {
        const { shopCartIds, ...other } = data;
        return this._get(`/productOrder/calculateOrderPrice/${shopCartIds}`, other);
    }



}

const confirmOrderApi = new ConfirmOrderApi();

export default confirmOrderApi;